#include "common.h"

class Solution {
public:
    bool isSymmetric(TreeNode* root) {
        if(!root) return true;
        return symmetric(root->left, root->right);
    }

    bool symmetric(TreeNode* p, TreeNode* q)
    {
      if(!p && !q) return true;
      if(!p || !q) return false;
      return (p->val == q->val) && symmetric(p->left, q->right) && symmetric(p->right, q->left);
    }
};